﻿@using Aspire.Dashboard.Model.Otlp
@inject IStringLocalizer<Resources.StructuredLogs> Loc

@{
    var logLevelSelectId = $"log-level-select-{Guid.NewGuid():N}";
}

@if (ViewportInformation.IsDesktop)
{
    <FluentInputLabel slot="end"
                      Label="@Loc[nameof(Dashboard.Resources.StructuredLogs.StructuredLogsLevels)]"
                      ForId="@logLevelSelectId"
                      Orientation="@(ViewportInformation.IsDesktop ? Orientation.Horizontal : Orientation.Vertical)" />

    <DesktopToolbarDivider />

    <FluentSelect TOption="SelectViewModel<LogLevel?>"
                  Id="@logLevelSelectId"
                  Items="@LogLevels"
                  Position="SelectPosition.Below"
                  OptionText="@(c => c.Name)"
                  @bind-SelectedOption="@LogLevel"
                  @bind-SelectedOption:after="@HandleSelectedLogLevelChangedInternalAsync"
                  Width="120px"
                  Style="min-width: auto;"
                  AriaLabel="@Loc[nameof(Resources.StructuredLogs.StructuredLogsSelectMinimumLogLevel)]"
                  @attributes="@AdditionalAttributes" />
}
else
{
    <div>
        <FluentSelect TOption="SelectViewModel<LogLevel?>"
                      Id="@logLevelSelectId"
                      Items="@LogLevels"
                      Position="SelectPosition.Below"
                      OptionText="@(c => c.Name)"
                      Label="@Loc[nameof(Resources.StructuredLogs.StructuredLogsLevels)]"
                      @bind-SelectedOption="@LogLevel"
                      @bind-SelectedOption:after="@HandleSelectedLogLevelChangedInternalAsync"
                      Width="120px"
                      Style="min-width: auto;"
                      AriaLabel="@Loc[nameof(Resources.StructuredLogs.StructuredLogsSelectMinimumLogLevel)]"
                      @attributes="@AdditionalAttributes" />
    </div>
}
